﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Server
{   /// <summary>
    /// A class that represents a chat room
    /// </summary> 
    class Room
    {
        string roomname;
        public static List<Room> roomlist=new List<Room>();
        List<String> ActiveUser = new List<string>();
        static Room()
        {
            Room room = new Room("General");
            Room room2 = new Room("Movies");
            

        }
        public Room(string _roomname)
        {
            roomname = _roomname;
            roomlist.Add(this);
        }
        /// <summary>
        /// This is a function to add an active user to the ActiveUser list.
        /// </summary>
        /// <param name="_username">the user added</param>
        public void addActiveUser(string _username)
        {
            ActiveUser.Add(_username);
        }
        /// <summary>
        /// This is a function remove user from ActiveUser list, if user leaves the room
        /// </summary>
        /// <param name="_username">the user removed</param>
        public void removeActiveUser(string _username)
        {
            for (int i = 0; i < ActiveUser.Count; i++)
            {
                if (ActiveUser[i] == _username)
                {
                    ActiveUser.Remove(_username);
                }
            }
        }
        /// <summary>
        /// Return all of the users in the room.
        /// </summary>
        /// <returns></returns>
        public string[] sendActiveuser()
        {
            string[] UsersName = new string[ActiveUser.Count];
            for (int i = 0; i < ActiveUser.Count; i++)
            {
                UsersName[i] = ActiveUser[i];
            }
            return UsersName;
        }

        public static string[] sendRoomName()
        {
            string[] RoomName = new string[roomlist.Count];
            for (int i = 0; i < roomlist.Count; i++)
            {
                RoomName[i] = roomlist[i].roomname;
            }
            return RoomName;
        }
    }
}
